package com.yitiao.controller;

import com.yitiao.dao.SpringCloudDaoImpl;
import com.yitiao.entry.SpringCloud;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/mongo")
@AllArgsConstructor
public class MainController {
    private final SpringCloudDaoImpl cloudDao;

    @GetMapping("/findAll")
    public void findAll(){
        System.out.println(cloudDao.findAll());
    }

    @GetMapping("/findById")
    public void findById(String id){
        System.out.println(cloudDao.findById(id));
    }

    @GetMapping("/addOne")
    public void addOne(){
        cloudDao.addOne(SpringCloud.builder()
                .age("12")
                .name("张三啊")
                .build());
    }
}
